package Stack_Queue;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2024-10-22
 * Time: 13:59
 */

class CircularQueue {
    private int[] queue;
    private int front, rear, capacity;

    public CircularQueue(int size) {
        queue = new int[size];
        front = rear = 0;
        capacity = size;
    }

    public boolean isFull() {
        return (rear + 1) % capacity == front;
    }

    public boolean isEmpty() {
        return front == rear;
    }

    public void enqueue(int value) {
        if (isFull()) {
            throw new IllegalStateException("Queue is full");
        }
        queue[rear] = value;
        rear = (rear + 1) % capacity;
    }

    public int dequeue() {
        if (isEmpty()) {
            throw new IllegalStateException("Queue is empty");
        }
        int value = queue[front];
        front = (front + 1) % capacity;
        return value;
    }

    public int size() {
        return (rear - front + capacity) % capacity;
    }

    public int get(int index) {
        return queue[(front + index) % capacity];
    }

    public void set(int index, int value) {
        queue[(front + index) % capacity] = value;
    }
}

public class YangHuiTriangle {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); // 输入的行数
        printYangHuiTriangle(n);
    }

    public static void printYangHuiTriangle(int n) {
        if (n <= 0) return;

        // 创建循环队列，最多需要 n 个元素
        CircularQueue queue = new CircularQueue(n);

        for (int i = 0; i < n; i++) {
            // 每行的开始位置
            int[] currentRow = new int[i + 1];
            currentRow[0] = 1; // 第一列始终为 1
            currentRow[i] = 1; // 最后一列始终为 1

            // 计算当前行中间的值
            for (int j = 1; j < i; j++) {
                currentRow[j] = queue.get(j - 1) + queue.get(j);
            }

            // 打印当前行
            printRow(currentRow);

            // 将当前行入队
            for (int j = 0; j <= i; j++) {
                queue.set(j, currentRow[j]);
            }
        }
    }

    public static void printRow(int[] row) {
        // 打印行前空格以实现中心对齐
        for (int i = row.length; i < row.length + 6; i++) {
            System.out.print(" ");
        }
        // 打印当前行
        for (int value : row) {
            System.out.print(value + " ");
        }
        System.out.println();
    }
}